import {defHttp} from '/@/utils/http/axios';
import {BasicPageSearchParams} from "/@/api/model/baseModel";

// 数据权限api

enum Api {
  list = '/SysUserDataRange/list',
  view = '/SysUserDataRange/view',
  add = '/SysUserDataRange/add',
  update = '/SysUserDataRange/update',
  del = '/SysUserDataRange/del/',
}

export const list = (params?: any) => {
  const query = params && { pageNum: params.pageNum, pageSize: params.pageSize };
  let entity = params || {};
  if (entity) {
    delete entity['pageNum'];
    delete entity['pageSize'];
  }
  const queryParam = { query, entity } as BasicPageSearchParams<any>;
  return defHttp.post<any>({ url: Api.list, params: queryParam });
};

export const view = (params) => {
  return defHttp.get<any>({ url: Api.view, params });
};

export const add = (params) =>
  defHttp.post<any>({ url: Api.add, params });

export const update = (params) =>
  defHttp.post<any>({ url: Api.update, params });

export const del = (id?: number) =>
  defHttp.post<any>({ url: Api.del + id });

